# source:https://leetcode.cn/problems/minimum-size-subarray-sum/  滑动窗口
class Solution:
    def minSubArrayLen(self, target: int, nums: List[int]) -> int:
        i = 0
        cnt = 0
        ans = inf
        for j, v in enumerate(nums):
            cnt += v 
            while cnt >= target:
                ans = min(ans, j-i+1)
                cnt -= nums[i]
                i += 1        
        return ans if ans != inf else 0